package com.wengen.mvc.controller;

import com.wengen.mvc.annotation.WenAutowired;
import com.wengen.mvc.annotation.WenController;
import com.wengen.mvc.annotation.WenRequestMapping;
import com.wengen.mvc.annotation.WenRequestParam;
import com.wengen.mvc.service.WengenService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Auther: 朱稳根
 * @Date: 2018/8/25 23:05
 * @Description:
 */
@WenController
@WenRequestMapping("/wengen")
public class WengenController {

    @WenAutowired("WengenServiceImpl")
    private WengenService wengenService;

    @WenRequestMapping("/getWengen")
    public void getWengen(HttpServletRequest request, HttpServletResponse response,
                          @WenRequestParam("name")String name,@WenRequestParam("sex")String sex){
        String result = wengenService.getWengen(name, sex);
        PrintWriter pw;
        try {
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            pw = response.getWriter();
            pw.write(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
